------------General Swep Info---------------
SWEP.Author   	    = ""
SWEP.Contact        = ""
SWEP.PrintName			= ""
SWEP.Purpose        = ""
SWEP.Instructions   = ""
SWEP.Spawnable      = false  --Can a client spawn this?
SWEP.AdminSpawnable  = true  --Can an Admin spawn this?
SWEP.HoldType			   	= "pistol"
--SWEP.Base = "weaponbase"
-----------------------------------------------

------------Models---------------------------
SWEP.ViewModel      = "models/weapons/v_thompson.mdl"
SWEP.WorldModel   = "models/weapons/w_thompson.mdl"
-----------------------------------------------

-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= .1	--In seconds
SWEP.Primary.Recoil			= 5		--Gun Kick
SWEP.Primary.Damage			= 5	--Damage per Bullet
SWEP.Primary.NumShots		= 1		--Number of shots per one fire
SWEP.Primary.Cone			= Vector( .05, .05, .05 )	--Bullet Spread
SWEP.Primary.ClipSize		= 30	--Use "-1 if there are no clips"
SWEP.Primary.DefaultClip	= 30	--Number of shots in next clip
SWEP.Primary.Automatic   	= true	--Pistol fire (false) or SMG fire (true)
SWEP.Primary.Ammo         	= "smg1"	--Ammo Type
-------------End Primary Fire Attributes------------------------------------
 
--[[-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay		= 0.9
SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
SWEP.Secondary.NumShots		= 1
SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= false
SWEP.Secondary.Ammo         = "none"
-------------End Secondary Fire Attributes--------------------------------]]--
 
/*---------------------------------------------------------
   Name: SWEP:Think()
   Desc: Called every frame.
---------------------------------------------------------*/
function SWEP:Think()
end


/*---------------------------------------------------------
   Name: SWEP:Precache( )
   Desc: Use this function to precache stuff
---------------------------------------------------------*/
function SWEP:Precache()
end


/*---------------------------------------------------------
   Name: SWEP:Initialize()
   Desc: Called when the swep is spawned.
---------------------------------------------------------*/
function SWEP:Initialize()
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	if SERVER then
		self:SetWeaponHoldType( self.HoldType )
	end
end

function SWEP:MuzzleFlash( offset )
	local effect, att, t
	
	att = self:LookupAttachment( "1" )
	
	t = self:GetAttachment( att )
	
	effect = EffectData( )
		effect:SetStart( t.Pos + ( offset or Vector( 0, 0, 0 ) ) + t.Ang:Forward( ) * 8 )
		effect:SetNormal( t.Ang:Forward( ) )
	util.Effect( "MuzzleFlash", effect )
end

/*---------------------------------------------------------
   Name: SWEP:PrimaryAttack
   Desc: Called when left  mouse button is pressed.
---------------------------------------------------------*/
function SWEP:PrimaryAttack()
	// Make sure we can shoot first
	if ( !self:CanPrimaryAttack() ) then return end

	// Play shoot sound
	self.Weapon:EmitSound("weapons/smg1/smg1_fire1.wav")	 
	
	// Remove 1 bullet from our clip
	self:TakePrimaryAmmo( 1 )
	
	// Punch the player's view
	self.Owner:ViewPunch( Angle( -5, 0, 0 ) )
	
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
	
	self.Owner:MuzzleFlash()
	
end

/*---------------------------------------------------------
   Name: SWEP:SecondaryAttack()
   Desc: Called when +attack2 is called.
---------------------------------------------------------*/
function SWEP:SecondaryAttack()

end

function SWEP:ShootEffects() 
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )	// View model animation  	
	self.Owner:MuzzleFlash()				// Crappy muzzle light  	
	self.Owner:SetAnimation( PLAYER_ATTACK1 )		// 3rd Person Animation     
end  

/*---------------------------------------------------------
   Name: SWEP:ShootBullet( )
   Desc: A convenience function to shoot bullets
---------------------------------------------------------*/
function SWEP:ShootBullet()
	
	local bullet = {}  
	bullet.Num = self.Primary.NumShots
	bullet.Src = self.Owner:GetShootPos()	// Source  	
	bullet.Dir 		= self.Owner:GetAimVector()	// Dir of bullet  
	bullet.Spread 	= self.Primary.Cone		// Aim Cone  
	bullet.Tracer	= 1				// Show a tracer on every x bullets 
  	bullet.Force	= 1					// Amount of force to give to phys objects  
	bullet.Damage	= self.Primary.Damage 
	bullet.AmmoType = self.Primary.Ammo	
	
	self.Owner:FireBullets( bullet )
	
end